import { reactive } from 'vue';

/**
 * 表单领用设备长度校验
 */
const assetListLengthValidator = (list: AppSysAssetChange.AssetDto[]) => list.length > 0;

const formRules = {
  changeTime: [{ required: true, message: '请选择领用时间' }],
  deptId: [{ required: true, message: '请选择领用部门' }],
  userId: [{ required: true, message: '请选择领用人' }],
  assetList: [
    {
      validator: assetListLengthValidator,
      message: '请选择领用设备',
    },
  ],
};

const state = reactive<{
  /**
   * 领用部门选择器是否显示
   */
  organDtosPickerIsShow: boolean;
  /**
   * 当前用户组织
   */
  organDtos: AppSysOrgan.Dto[];
  /**
   * 领用日历是否显示
   */
  changeTimeCalendarIsShow: boolean;
  /**
   * 资产列表弹出层是否显示
   */
  appAssetListPopupIsShow: boolean;
}>({
  organDtosPickerIsShow: false,
  organDtos: [],
  changeTimeCalendarIsShow: false,
  appAssetListPopupIsShow: false,
});

export { formRules, state };
